<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>v-bind动态绑定style(对象、数组语法)</title>
</head>
<style>
</style>

<body>

  <div id="app">
    <!-- 对象语法 -->
    <!-- <h2 :style="{key(属性名):value(属性值)}">{{message}}</h2> -->
    <!-- 加单引号,当成字符串解析,没有意义,是固定的 -->
    <!-- <h2 :style="{fontSize:'50px'}">{{message}}</h2> -->
    <!-- 不加单引号，当成变量解析 -->
    <h2 :style="{backgroundColor: bgc, fontSize: fz}">{{message}}</h2>
    
    <!-- 数组语法 -->
    <h2 :style="[baseStyle, baseStyle1]">{{message}}</h2> <!-- 跟动态绑定class(数组语法)一样 -->
    
    <h2 :style="getStyle()">{{message}}</h2>
  </div>

  <script src="../js/vue.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        message: 'hello world!',
        bgc: 'grey',
        fz: '30px',
        baseStyle: { backgroundColor: 'red' },
        baseStyle1: { fontSize: '50px' },
      },
      methods: {
        getStyle() {
          return [this.baseStyle, this.baseStyle1];
        }
      },
    })
  </script>

</body>

</html>